﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title></title>
    <link href="../CSS/style1.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/style4.css" rel="stylesheet" type="text/css" />
    <script src="../Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.showModalDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        //时间格式转换
        function date2str(date) {
            //null判断
            if (date == null) return "";
            //去掉左右的斜杠
            date = date.replace(/\//g, "");
            //将其转为一个日期对象
            eval("var d = new " + date + ";");
            //返回最终结果
            return d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
        }
        //得到ID
        var ID = window.dialogArguments.id;
        //加载显示
        $(function () {
            reloadList();
        })
        function reloadList() {
            //通过id将资料从数据库中查询出来
            $.ajax({
                url: "QuanBuAll.asmx/FindCustomers",
                type: "post",
                data: JSON.stringify({ id: parseInt(ID) }),
                dataType: "json",
                contentType: "application/json",
                success: function (obj) {
                    $("#Label1").text(obj.d.CusID) || "";
                    $("#Text1").val(obj.d.CusMan) || "";
                    $("#Text2").val(obj.d.CusName) || "";
                    $("#Text3").val(obj.d.CusZip) || "";

                    $("#Text4").val(obj.d.CusAddress) || "";
                    $("#Label2").text(date2str(obj.d.CusDate)) || "";
                    $("#Text5").val(obj.d.CusFax) || "";
                    $("#Text6").val(obj.d.CusWebsite) || "";

                    $("#Text7").val(obj.d.CusLicenceNo) || "";
                    $("#Text8").val(obj.d.CusChieftain) || "";
                    $("#Text9").val(obj.d.CusBankroll) || "";
                    $("#Text10").val(obj.d.CusTurnover) || "";

                    $("#Text11").val(obj.d.CusBank) || "";
                    $("#Text12").val(obj.d.CusBankNo) || "";
                    $("#Text13").val(obj.d.CusLocalTaxNo) || "";
                    $("#Text14").val(obj.d.CusNationalTaxNo) || "";
                    if (obj.d.CusState == "1") $("#Label3").text("正常") || "";
                    if (obj.d.CusState == "2") $("#Label3").text("流失") || "";
                }, error: function (xmlhttp) {
                    alert("错误：" + xmlhttp.responseText);
                }
            });
        }
        function showEmp() {

            $.showModalDialog("../publicPage/SelectEmp.htm?data=" + Math.random(), null, 200, 220, function (UserID) {
                if (UserID) {
                    var cus = {
                        action: "updateCustomer",
                        ID: parseInt(ID),
                        UserID: parseInt(UserID)
                    };
                    $.get("CustomerAll.ashx", cus, function (r) {
                        if (r == "1") {

                            reloadList();

                        } else {
                            alert("客户经理选择失败");
                        }
                    });
                }
            });
        };
        //确认操作修改
        function ok() {
            var cus = {
                action: "CustomerEdit",
                ID: ID,
                CusName: $("#Text2").val() ,
                CusZip: $("#Text3").val(),
                CusAddress: $("#Text4").val(),
                CusFax: $("#Text5").val(),
                CusWebsite: $("#Text6").val() ,
                CusLicenceNo: $("#Text7").val() ,
                CusChieftain: $("#Text8").val() ,
                CusBankroll: $("#Text9").val() ,
                CusTurnover: $("#Text10").val() ,
                CusBank: $("#Text11").val() ,
                CusBankNo: $("#Text12").val() ,
                CusLocalTaxNo: $("#Text13").val() ,
                CusNationalTaxNo: $("#Text14").val()
            };
            //发起更新请求
            $.get("CustomerAll.ashx", cus, function (r) {
                if (r == "1") {
                    alert("客户信息修改成功");
                    window.returnValue = true;
                    window.close();
                } else {
                    alert("客户信息修改失败"); 
                }
            });
        }
        
    </script>
</head>
<body>
<table class="tableEdit" id="tab">
        <thead>
            <tr>
                <td colspan="4">客户信息编辑</td>
            </tr>
        </thead>
        <tr>
            <th>客户编号：</th>
            <td><label id="Label1" style="color:red"></label></td>
            <th>客户经理：</th>
            <td><input type="text" style="color:red;width:100px" id="Text1" readonly="readonly" ondblclick="showEmp();" /></td>
        </tr>
        <tr>
            <th>客户名称：</th>
            <td>
                <input type="text" id="Text2" style="color:blue;width:120px" />
             </td>
            <th>邮政编码：</th>
            <td><input type="text" id="Text3" style="color:orange;width:50px" />
            </td>
        </tr>
        <tr>
            <th>地址：</th>
            <td colspan="3">
                <input type="text" id="Text4" style="color:purple;width:86%"/>
            </td>
            
        </tr>
        <tr>
            <th>传真：</th>
            <td>
                <input type="text" id="Text5" style="color:green;" />
             </td>
            <th>Email：</th>
            <td><input type="text" id="Text6" style="color:blue;width:120px" />
            </td>
        </tr>
         <tr>
            <th>营业执照注册号：</th>
            <td>
                <input type="text" id="Text7" style="color:pink" />
             </td>
            <th>法人：</th>
            <td><input type="text" id="Text8" style="color:blue;width:60px" />
            </td>
        </tr>
        <tr>
            <th>注册资金：</th>
            <td>
                <input type="text" id="Text9" style="width:54px;color:purple" /><label style="color:Red">单位:万</label>
             </td>
            <th>年营业额：</th>
            <td><input type="text" id="Text10" style="color:orange;width:54px" /><label style="color:Red">单位:万</label>
            </td>
        </tr>
        <tr>
            <th>开户银行：</th>
            <td>
                <input type="text" id="Text11" style="color:green;width:170px" />
             </td>
            <th>银行账号：</th>
            <td><input type="text" id="Text12" style="color:gray;width:140px" />
            </td>
        </tr>
        <tr>
            <th>地税登记号：</th>
            <td>
                <input type="text" id="Text13" style="color:purple;width:130px" />
             </td>
            <th>国税登记号：</th>
            <td><input type="text" id="Text14" style="color:blue;width:130px" />
            </td>
        </tr>
        <tr>
            <th>创建时间：</th>
            <td><label id="Label2" style="color:red"></label></td>
            <th>状态：</th>
            <td><label id="Label3" style="color:red"></label></td>
        </tr>
        <tfoot>
            <tr>
                <td colspan="4" style="text-align:center">
                    <input type="button" value="确定" onclick="ok();" />&nbsp;&nbsp;
                    <input type="button" value="关闭" onclick="window.close()" />
                </td>
            </tr>
        </tfoot>
    </table>
</body>
</html>
